﻿//-----------------------------------------------------------------------
// <copyright file="ServiceCollectionExtensions.cs" company="SLWY Enterprises">
// * Copyright (C) 2017 四川商旅无忧科技有限公司 版权所有。
// * version : 1.0
// * author  : qinchaoyue
// * FileName: ServiceCollectionExtensions.cs
// * history : created by qinchaoyue 2017-10-24 11:16:03
// </copyright>
//-----------------------------------------------------------------------

using AutoMapper;
using Microsoft.Extensions.DependencyInjection;

namespace Slwy.FrameCore.Mapping
{
    /// <summary>
    /// mapper 服务注册类
    /// </summary>
    public static class ServiceCollectionExtensions
    {
        /// <summary>
        /// 注册 mapper 服务
        /// </summary>
        /// <param name="services">服务集合</param>
        public static void AddAutoMapperClasses(this IServiceCollection services)
        {
            var profiles = new MapperTypeFinder().FindAll();

            //Mapper.Initialize(cfg =>
            //{
            //    foreach (var profile in profiles)
            //    {
            //        cfg.AddProfile(profile);
            //    }
            //});
            services.AddSingleton(Mapper.Configuration);
        }
    }
}
